;; Tests of the Non-robust computational geometry functions
;; Copyright (C) 2021  Rocks Mazama
;; 
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; 
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;; 
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

(ns mazama.compgeom.spline-test
  (:require
   [clojure.test :refer [deftest is testing]]
   [mazama.compgeom.spline :as spline]))

(deftest open-relaxed-cubic-bezier-spline-test
  (testing "https://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf, Section 5"
    (let [S [[1 -1] [-1 2] [1 4] [4 3] [7 5]]
          bezier (spline/open-relaxed-cubic-bezier-spline S)]
      (is (= (count bezier) 4))
      (is (= [[1 -1] [0 0] [-1 1] [-1 2]] (nth bezier 0)))
      (is (= [[-1 2] [-1 3] [0 4] [1 4]] (nth bezier 1)))
      (is (= [[1 4] [2 4] [3 3] [4 3]] (nth bezier 2)))
      (is (= [[4 3] [5 3] [6 4] [7 5]] (nth bezier 3))))))
